home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
tex
/
td187src.lzh
/
OWNBOXES.I
< prev
next >
Wrap
Text File
|
1991-12-14
|
14KB
|
413 lines
IMPLEMENTATION MODULE OwnBoxes;
FROM SYSTEM IMPORT ADR;
FROM CommonData IMPORT ClipXY, SnapMode, SnapX, SnapY,
XSnap, YSnap, InternalResolution,
WindowHandle;
FROM Variablen IMPORT NumberToStr, Position, PicToPix, PixToPic;
IMPORT MagicAES, MagicVDI, MagicSys;
IMPORT MagicStrings, MagicConvert;
IMPORT mtAppl;
IMPORT Diverses;
IMPORT MathLib0;
(*
IMPORT PDebug;
*)
PROCEDURE SetMousePos(X, Y : INTEGER);
VAR idummy : INTEGER;
bdummy : BITSET;
cdummy : CHAR;
BEGIN
(* Tja, wie geht das nur ? *)
(* nach ST-Computer 11/88 S.183 *)
(* put mouse in sample mode *)
idummy := MagicVDI.SetInputmode(mtAppl.VDIHandle, MagicVDI.Mouse, MagicVDI.Sample);
bdummy := MagicVDI.InputLocatorSM(mtAppl.VDIHandle, X, Y, idummy, idummy, cdummy);
(* put mouse in request mode *)
idummy := MagicVDI.SetInputmode(mtAppl.VDIHandle, MagicVDI.Mouse, MagicVDI.Request);
END SetMousePos;
PROCEDURE GetMKState(VAR MoX, MoY : INTEGER;
VAR MoBut, KState : BITSET );
BEGIN
MagicVDI.SampleKeyboard(mtAppl.VDIHandle, KState);
MagicVDI.SampleMouse(mtAppl.VDIHandle, MoBut, MoX, MoY);
END GetMKState;
PROCEDURE MousePos ( VAR PixMouseX, PixMouseY : INTEGER;
VAR PicMouseX, PicMouseY : INTEGER;
VAR LeftButtonPressed : BOOLEAN;
VAR RightButtonPressed : BOOLEAN);
(* Berücksichtigt SnapMode *)
VAR xpix, ypix, oldx, oldy, xpic, ypic, x, y, z : INTEGER; but, key : BITSET;
BEGIN
GetMKState(xpix, ypix, but, key);
PixToPic(xpix, ypix, xpic, ypic);
IF SnapMode AND NOT (MagicAES.KCTRL IN key) THEN
(* Runde auf nächsten Wert *)
oldx := xpic;
oldy := ypic;
IF XSnap THEN
z := ABS(xpic);
x := z DIV (SnapX * InternalResolution);
y := x * SnapX * InternalResolution;
IF (z - y) > ((SnapX * InternalResolution) DIV 2) THEN
INC(x);
END;
IF xpic<0 THEN
xpic := - x * SnapX * InternalResolution;
ELSE
xpic := x * SnapX * InternalResolution;
END;
END;
IF YSnap THEN
z := ABS(ypic);
x := z DIV (SnapY * InternalResolution);
y := x * SnapY * InternalResolution;
IF (z - y) > ((SnapY * InternalResolution) DIV 2) THEN
INC(x);
END;
IF ypic<0 THEN
ypic := - x * SnapY * InternalResolution;
ELSE
ypic := x * SnapY * InternalResolution;
END;
END;
PicToPix(x, y, xpic, ypic);
IF oldx<>xpic THEN
xpix := x;
END;
IF oldy<>ypic THEN
ypix := y;
END;
END;
LeftButtonPressed := MagicAES.MouseLeft IN but;
RightButtonPressed := MagicAES.MouseRight IN but;
PixMouseX := xpix;
PixMouseY := ypix;
PicMouseX := xpic;
PicMouseY := ypic;
END MousePos;
PROCEDURE WaitForDepress(VAR x, y : INTEGER);
VAR dum : INTEGER; lbut, rbut : BOOLEAN;
BEGIN
REPEAT
MousePos(x, y, dum, dum, lbut, rbut);
UNTIL NOT lbut;
END WaitForDepress;
PROCEDURE ChangeBox( StartX, StartY : INTEGER;
VAR Width, Heigth : INTEGER;
ChangeX, ChangeY : BOOLEAN;
RevrsSignAllowed : BOOLEAN;
ShowPercentage : BOOLEAN);
(* Erlaubt das Aussehen des Rechtecks zu verändern. Die Flags geben
an, ob eine Änderung in der entsprechenden Richtung erlaubt ist *)
VAR i, dum, dumx, dumy,
x, y, xo, yo : INTEGER;
pxy : ARRAY [0..3] OF INTEGER;
(**
but, key : BITSET;
**)
xy, xyo : ARRAY [0..9] OF INTEGER;
DelX, DelY : INTEGER;
StartWd, StartHt : INTEGER;
LeftBut, RightBut : BOOLEAN;
txt, tmp : ARRAY [0..59] OF CHAR;
factor : LONGREAL;
PROCEDURE AddReal(r : LONGREAL; aftcom : CARDINAL; VAR str : ARRAY OF CHAR);
VAR i, len : CARDINAL;
prezero, aftzero : INTEGER;
tmpreal : LONGREAL;
blank : ARRAY [0..1] OF CHAR;
tmpstr : ARRAY [0..19] OF CHAR;
BEGIN
blank := ' ';
prezero := Diverses.round(MathLib0.int(r));
tmpreal := MathLib0.fraction(r);
FOR i:=1 TO aftcom DO
tmpreal := tmpreal * 10.0;
END;
aftzero := Diverses.round(tmpreal);
MagicConvert.IntToStr(prezero, 6, tmpstr);
MagicStrings.Append(tmpstr, str);
len := MagicStrings.Length(str);
str[len] := '.';
str[len+1] := 0C;
MagicConvert.IntToStr(aftzero, aftcom, tmpstr);
FOR i:=0 TO MagicStrings.Length(tmpstr) DO
IF tmpstr[i] = ' ' THEN tmpstr[i] := '0'; END;
END;
MagicStrings.Append(tmpstr, str);
END AddReal;
PROCEDURE NoRev(xy, StartXY, StartExt : INTEGER) : BOOLEAN;
VAR delta : INTEGER;
BEGIN
IF RevrsSignAllowed OR (StartExt = 0) THEN
RETURN TRUE;
ELSE
delta := xy - StartXY;
IF delta=0 THEN
RETURN TRUE;
ELSE
RETURN NOT
(((delta<0) AND (StartExt>0)) OR
((delta>0) AND (StartExt<0)));
END;
END;
END NoRev;
BEGIN
(*
IF ChangeX THEN
PDebug.Message('X darf verändert werden.');
END;
IF ChangeY THEN
PDebug.Message('Y darf verändert werden.');
END;
PDebug.ShowWord('StartX = ', StartX);
PDebug.ShowWord('StartY = ', StartY);
PDebug.ShowWord('Width = ', Width);
PDebug.ShowWord('Heigth = ', Heigth);
*)
StartWd := Width; IF StartWd = 0 THEN StartWd := 1; END;
StartHt := Heigth; IF StartHt = 0 THEN StartHt := 1; END;
MagicVDI.SetLineEndstyles ( mtAppl.VDIHandle , MagicVDI.Cornerd , MagicVDI.Cornerd ) ;
dum := MagicVDI.SetLinetype ( mtAppl.VDIHandle , MagicVDI.User ) ;
i := 5555H; (* ...... *)
MagicVDI.SetUserlinestyle ( mtAppl.VDIHandle , i ) ;
dum := MagicVDI.SetLinewidth ( mtAppl.VDIHandle , 1 ) ;
dum := MagicVDI.SetLinecolor ( mtAppl.VDIHandle , MagicAES.BLACK ) ;
FOR i := 0 TO 4 DO
xy [ 2*i ] := StartX ;
xy [ 2*i + 1 ] := StartY ;
END ;
xy[2] := xy[2] + Width; xy[4] := xy[4] + Width;
xy[5] := xy[5] + Heigth; xy[7] := xy[7] + Heigth;
FOR i:=0 TO 9 DO
xyo[i] := xy[i];
END;
xo := StartX ; yo:=StartY ;
dum := MagicVDI.SetWritemode ( mtAppl.VDIHandle , MagicVDI.XOR ) ;
MagicVDI.SetClipping ( mtAppl.VDIHandle , ClipXY , TRUE ) ;
Diverses.MouseOff;
MagicVDI.Polyline ( mtAppl.VDIHandle , 5 , xyo ) ; (* erstmals zeichnen *)
Diverses.MouseFinger;
MagicVDI.SetClipping ( mtAppl.VDIHandle , ClipXY , FALSE) ;
DelX := StartX; DelY := StartY;
(**
GetMKState(x, y, but, key);
**)
MousePos ( x, y, dumx, dumy, LeftBut, RightBut);
(**
WHILE (MagicAES.MouseLeft IN but) DO (* linke Taste ist gedrückt *)
**)
WHILE (LeftBut) DO (* linke Taste ist gedrückt *)
IF (( x <> xo ) AND ChangeX) OR
(( y <> yo ) AND ChangeY) THEN
IF ChangeX AND NoRev(x, StartX, StartWd) THEN
xy [ 2 ] := x ; xy [ 4 ] := x ;
ELSE
DelX := x;
END;
IF ChangeY AND NoRev(y, StartY, StartHt) THEN
xy [ 5 ] := y ; xy [ 7 ] := y ;
ELSE
DelY := y;
END;
IF ChangeX AND ChangeY AND LeftBut AND RightBut THEN
(* proportionales Aufziehen *)
(* muß noch implementiert werden *)
END;
Position (TRUE, x, y, DelX, DelY ) ;
IF ShowPercentage THEN
(* jetzt gib noch in die Info-Zeile des Fensters den
momentanen Änderungsfaktor aus... *)
txt := 'X: ';
i := ABS(xy[2] - StartX);
factor := MathLib0.real(i) / MathLib0.real(StartWd) * 100.0;
AddReal(factor, 2, txt);
MagicStrings.Append('%, Y: ', txt);
i := ABS(xy[5] - StartY);
factor := MathLib0.real(i) / MathLib0.real(StartHt) * 100.0;
AddReal(factor, 2, txt);
MagicStrings.Append(tmp, txt);
MagicStrings.Append('% ', txt);
pxy[0] := MagicSys.CastToInt(ADR ( txt ) DIV 10000H);